<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div></div>
    <script>
        // getTime();
        // function getTime(){
        //     setTimeout(function(){
        //         const div=document.querySelector('div');
        //         const date=new Date();
        //         const year=date.getFullYear();
        //         const month=date.getMonth()+1;
        //         const day=date.getDate();
        //         const h=date.getHours();
        //         const m=date.getMinutes();
        //         const s=date.getSeconds();
        //         div.innerHTML=`${year}年${month}月${day}日${h}时${m}分${s}秒`;
        //         getTime();
        //     },1000)

        // }

        // getTime();

        // function getTime() {

        //     const div = document.querySelector('div');
        //     const date = new Date();
        //     const year = date.getFullYear();
        //     const month = date.getMonth() + 1;
        //     const day = date.getDate();
        //     const h = date.getHours();
        //     const m = date.getMinutes();
        //     const s = date.getSeconds();
        //     div.innerHTML = `${year}年${month}月${day}日${h}时${m}分${s}秒`;

        //     setTimeout(function () {
        //         getTime();
        //     }, 1000);
        // }


        function getTime() {
            const div = document.querySelector('div');
            const date = new Date();
            const year = date.getFullYear();
            const month = date.getMonth() + 1;
            const day = date.getDate();
            const h = date.getHours();
            const m = date.getMinutes();
            const s = date.getSeconds();
            div.innerHTML = `${year}年${month}月${day}日${h}时${m}分${s}秒`;
        }
        setInterval(() => {
            getTime();
        }, 1000);

    </script>
</body>

</html>